package com.ycg.vue.modules.system.controller;

import com.ycg.vue.result.WeatherResponse;
import com.ycg.vue.utils.WeatherUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description 天气获取接口
 * @Author jink
 * @Date 2024/8/28
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {

    private final WeatherUtils weatherService;

    public WeatherController(WeatherUtils weatherService) {
        this.weatherService = weatherService;
    }

    @GetMapping("/getWeather")
    public WeatherResponse getWeather(@RequestParam String location) {
        return weatherService.getWeather(location);
    }

    @GetMapping("/getWeatherByString")
    public String getWeatherByString(@RequestParam String location) {
        return weatherService.getWeatherByString(location);
    }
}
